﻿package _me {
	import _Pan3D.program.Program3DManager;
	
	import com.adobe.utils.AGALMiniAssembler;
	
	import flash.display.BitmapData;
	import flash.display.Stage;
	import flash.display3D.*;
	import flash.events.Event;

	// --------------MSN:lation_pan@live.cn  QQ: 3423526------------- //
	public class Config {
		private static var config_end : Function;
		

		public static function init(_stage : Stage, _config_end : Function) : void {
			
			
			config_end = _config_end;
			Scene_data.stage = _stage;
			Scene_data.stage3D = Scene_data.stage.stage3Ds[0];
			Scene_data.stage3D.addEventListener(Event.CONTEXT3D_CREATE, myContext3DHandler);
			Scene_data.stage3D.requestContext3D();
		}

		private static function myContext3DHandler(evt : Event) : void {
			Scene_data.context3D = Scene_data.stage3D.context3D;
			restConfigContext3D();
			Scene_data.ready = true;
			Program3DManager.getInstance().initReg();
			Scene_data.texShadowMap=Scene_data.context3D.createTexture(1024,1024, Context3DTextureFormat.BGRA, false);
			Scene_data.texShadowMap.uploadFromBitmapData(new BitmapData(1024,1024,false,0xFFFFFFFF));
			config_end();

		}
		public static function restConfigContext3D():void
		{
			Scene_data.context3D.configureBackBuffer(Scene_data.stage.stageWidth, Scene_data.stage.stageHeight, 1, true);
			Scene_data.context3D.setCulling(Context3DTriangleFace.NONE);
		}
		
		

	
	}
}
